using System;
using System.Collections.Generic;
using System.Text;
using System.Net.NetworkInformation;
using System.Net;
using System.IO;
using System.Windows.Forms;
using System.ComponentModel;
using System.Xml;

namespace Nojin.Deployment
{

    public class Network
    {
        private static long roundTripTime;
        
        public static bool CheckSiteConnection(string siteIP)
        {
            IPAddress address = IPAddress.Parse(siteIP);
            return CheckSiteConnection(address);
        }

        public static bool CheckSiteConnection(IPAddress siteIP)
        {            
            byte[] bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 };
            Ping ping = new Ping();
            PingOptions options = new PingOptions(128, false);
            PingReply reply = ping.Send(siteIP, 10000, bytes, options);
            if (reply.Status == IPStatus.Success)
            {
                roundTripTime = reply.RoundtripTime;
                return true;
            }
            return false;
        }

    }
}
